Number of differences between 2 files 您所在的位置:网站首页 difference between two text Number of differences between 2 files

Number of differences between 2 files

#Number of differences between 2 files| 来源: 网络整理| 查看: 265

The UNIX and Linux Forums Login or Register to Ask a Question and Join Our Community Search Forums Tag Search Advanced Search Quick Links Contact Us Forum Rules Today's Posts FAQ Pictures & Albums All Albums Miscellaneous What is My IP Whois Mark Forums Read

UNIX for Dummies Questions & Answers Number of differences between 2 files Tags beginners Tag

  Thread Tools Search this Thread Top Forums UNIX for Dummies Questions & Answers Number of differences between 2 files # 1   Old 09-01-2003 sharuvman Registered User 18, 0 Member Information Avatar Join Date: Mar 2002 Last Activity: 8 December 2004, 1:38 AM EST Location: Bangalore,Karnataka State,India Posts: 18 Thanks Given: 0 Thanked 0 Times in 0 Posts Network Number of differences between 2 files Hi, "diff" command takes two file names as arguements and gives the difference between the two. How do I get the number of differences between two files ??? (Excluding whitespaces). Don't ask me to count number of lines produced by "diff". Thanks in advance, Sharath sharuvman View Public Profile for sharuvman Find all posts by sharuvman # 2   Old 09-01-2003 cerberusofhnsg Registered User 43, 0 Member Information Avatar Join Date: Jul 2003 Last Activity: 25 October 2003, 11:41 PM EDT Location: MT Posts: 43 Thanks Given: 0 Thanked 0 Times in 0 Posts diff file1 file2|wc -l will give you what you want, right? cerberusofhnsg View Public Profile for cerberusofhnsg Find all posts by cerberusofhnsg # 3   Old 09-01-2003 google Registered User 740, 3 Member Information Avatar Join Date: Jul 2002 Last Activity: 17 June 2009, 5:17 PM EDT Location: Atlanta Posts: 740 Thanks Given: 0 Thanked 3 Times in 2 Posts Quote: diff file1 file2|wc -l wc -l would simply count all of the differences found in file 1 + file 2. Be sure to use either the -b or the -w flag to ignore whitespace, tabs and other characters. To get a better picture of the comparison using diff, pipe the output to grep and grep for the lines with a '' symbol. That way, you will get lines that are different in file 1 or file 2. If you are working with data files that can be sorted, look at using the comm command. You may also look at using cmp to do a comparison. As always, see: man diff or man cmp or man comm Last edited by google; 09-01-2003 at 07:59 PM.. google View Public Profile for google Find all posts by google # 4   Old 09-01-2003 cerberusofhnsg Registered User 43, 0 Member Information Avatar Join Date: Jul 2003 Last Activity: 25 October 2003, 11:41 PM EDT Location: MT Posts: 43 Thanks Given: 0 Thanked 0 Times in 0 Posts sorry about that, read your post wrong. wc -l will not ignore whitespace. cerberusofhnsg View Public Profile for cerberusofhnsg Find all posts by cerberusofhnsg # 5   Old 09-03-2003 criglerj Registered User 129, 0 Member Information Avatar Join Date: May 2002 Last Activity: 7 September 2008, 10:24 PM EDT Location: Atlanta Posts: 129 Thanks Given: 0 Thanked 0 Times in 0 Posts It's unclear what you mean by "number of changes". Number of changed lines? Number of changed characters? Number of changed regions? Assuming the last of those (number of changed regions), one approach is to understand the output of diff. In Solaris diff (and most others, as I recall) the only lines that start with digits are the lines that specify the changed regions. so you can do this: Code: diff filea fileb | grep '^[1-9]' | wc -l or Code: diff filea fileb | awk '/^[1-9]/ {i++} END {print i}' But in either of these, you are at the mercy of diff, which may not have the same idea about what a "region" is as you do. With more modern diffs than I have at hand, e.g., gnu diff, you have a lot more options to control what diff shows as a difference region. criglerj View Public Profile for criglerj Find all posts by criglerj   Login or Register to Ask a Question Previous Thread | Next Thread 10 More Discussions You Might Find Interesting 1. Shell Programming and Scripting How to do find differences between 2 XML Files? Hello All, Requirement is to compare 2 XML files and see if there are any differences but from some of the providers We are receiving UTF-16 formatted XML file with no end of line as shown below. Excerpt of data file: 每镁


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有